using SS;
using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;
namespace TVSGPP.func
{
	public class frmAddSideEffects : Form
	{
		private IContainer components = null;
		private Label label1;
		private TextBox txtName;
		private TextBox txtAddress;
		private Label label2;
		private TextBox txtDiagnosis;
		private Label label3;
		private TextBox txtDrugsUsed;
		private Label label4;
		private Label label5;
		private TextBox txtDescription;
		private Label label6;
		private TextBox txtMeasures;
		private Label label7;
		private TextBox txtConclution;
		private Label label8;
		private DateTimePicker dtpDateStart;
		private Button btnClose;
		private Button btnSave;
		private Func objFunc = new Func();
		public string ID = "0";
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.label1 = new Label();
			this.txtName = new TextBox();
			this.txtAddress = new TextBox();
			this.label2 = new Label();
			this.txtDiagnosis = new TextBox();
			this.label3 = new Label();
			this.txtDrugsUsed = new TextBox();
			this.label4 = new Label();
			this.label5 = new Label();
			this.txtDescription = new TextBox();
			this.label6 = new Label();
			this.txtMeasures = new TextBox();
			this.label7 = new Label();
			this.txtConclution = new TextBox();
			this.label8 = new Label();
			this.dtpDateStart = new DateTimePicker();
			this.btnClose = new Button();
			this.btnSave = new Button();
			base.SuspendLayout();
			this.label1.AutoSize = true;
			this.label1.Location = new Point(11, 18);
			this.label1.Name = "label1";
			this.label1.Size = new Size(103, 15);
			this.label1.TabIndex = 0;
			this.label1.Text = "Người phản ảnh :";
			this.txtName.Location = new Point(118, 15);
			this.txtName.Name = "txtName";
			this.txtName.Size = new Size(436, 21);
			this.txtName.TabIndex = 1;
			this.txtAddress.Location = new Point(118, 42);
			this.txtAddress.Name = "txtAddress";
			this.txtAddress.Size = new Size(436, 21);
			this.txtAddress.TabIndex = 3;
			this.label2.AutoSize = true;
			this.label2.Location = new Point(63, 45);
			this.label2.Name = "label2";
			this.label2.Size = new Size(51, 15);
			this.label2.TabIndex = 2;
			this.label2.Text = "Địa chỉ :";
			this.txtDiagnosis.Location = new Point(118, 69);
			this.txtDiagnosis.Name = "txtDiagnosis";
			this.txtDiagnosis.Size = new Size(436, 21);
			this.txtDiagnosis.TabIndex = 5;
			this.label3.AutoSize = true;
			this.label3.Location = new Point(40, 72);
			this.label3.Name = "label3";
			this.label3.Size = new Size(74, 15);
			this.label3.TabIndex = 4;
			this.label3.Text = "Chẩn đoán :";
			this.txtDrugsUsed.Location = new Point(118, 96);
			this.txtDrugsUsed.Name = "txtDrugsUsed";
			this.txtDrugsUsed.Size = new Size(186, 21);
			this.txtDrugsUsed.TabIndex = 7;
			this.label4.AutoSize = true;
			this.label4.Location = new Point(19, 99);
			this.label4.Name = "label4";
			this.label4.Size = new Size(95, 15);
			this.label4.TabIndex = 6;
			this.label4.Text = "Thuốc đã dùng :";
			this.label5.AutoSize = true;
			this.label5.Location = new Point(310, 99);
			this.label5.Name = "label5";
			this.label5.Size = new Size(158, 15);
			this.label5.TabIndex = 8;
			this.label5.Text = "Ngày xuất hiện triệu chứng :";
			this.txtDescription.Location = new Point(118, 123);
			this.txtDescription.Name = "txtDescription";
			this.txtDescription.Size = new Size(436, 21);
			this.txtDescription.TabIndex = 11;
			this.label6.AutoSize = true;
			this.label6.Location = new Point(7, 126);
			this.label6.Name = "label6";
			this.label6.Size = new Size(107, 15);
			this.label6.TabIndex = 10;
			this.label6.Text = "Mô tả triệu chứng :";
			this.txtMeasures.Location = new Point(118, 150);
			this.txtMeasures.Name = "txtMeasures";
			this.txtMeasures.Size = new Size(436, 21);
			this.txtMeasures.TabIndex = 13;
			this.label7.AutoSize = true;
			this.label7.Location = new Point(18, 153);
			this.label7.Name = "label7";
			this.label7.Size = new Size(96, 15);
			this.label7.TabIndex = 12;
			this.label7.Text = "Biện pháp xử lý :";
			this.txtConclution.Location = new Point(118, 177);
			this.txtConclution.Name = "txtConclution";
			this.txtConclution.Size = new Size(436, 21);
			this.txtConclution.TabIndex = 15;
			this.label8.AutoSize = true;
			this.label8.Location = new Point(56, 180);
			this.label8.Name = "label8";
			this.label8.Size = new Size(58, 15);
			this.label8.TabIndex = 14;
			this.label8.Text = "Kết luận :";
			this.dtpDateStart.CustomFormat = "dd/MM/yyyy";
			this.dtpDateStart.Format = DateTimePickerFormat.Custom;
			this.dtpDateStart.Location = new Point(471, 96);
			this.dtpDateStart.Name = "dtpDateStart";
			this.dtpDateStart.Size = new Size(83, 21);
			this.dtpDateStart.TabIndex = 57;
			this.btnClose.FlatAppearance.BorderColor = Color.FromArgb(255, 128, 255);
			this.btnClose.FlatStyle = FlatStyle.Flat;
			this.btnClose.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnClose.Location = new Point(463, 214);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new Size(91, 26);
			this.btnClose.TabIndex = 58;
			this.btnClose.Text = "Thoát [ ESC ]";
			this.btnClose.UseVisualStyleBackColor = true;
			this.btnClose.Click += new EventHandler(this.btnClose_Click);
			this.btnSave.FlatAppearance.BorderColor = Color.FromArgb(255, 128, 255);
			this.btnSave.FlatStyle = FlatStyle.Flat;
			this.btnSave.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnSave.Location = new Point(332, 214);
			this.btnSave.Name = "btnSave";
			this.btnSave.Size = new Size(127, 26);
			this.btnSave.TabIndex = 59;
			this.btnSave.Text = "Lưu thông tin [ F6 ]";
			this.btnSave.UseVisualStyleBackColor = true;
			this.btnSave.Click += new EventHandler(this.btnSave_Click);
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			this.BackColor = Color.White;
			base.ClientSize = new Size(566, 251);
			base.Controls.Add(this.btnSave);
			base.Controls.Add(this.btnClose);
			base.Controls.Add(this.dtpDateStart);
			base.Controls.Add(this.txtConclution);
			base.Controls.Add(this.label8);
			base.Controls.Add(this.txtMeasures);
			base.Controls.Add(this.label7);
			base.Controls.Add(this.txtDescription);
			base.Controls.Add(this.label6);
			base.Controls.Add(this.label5);
			base.Controls.Add(this.txtDrugsUsed);
			base.Controls.Add(this.label4);
			base.Controls.Add(this.txtDiagnosis);
			base.Controls.Add(this.label3);
			base.Controls.Add(this.txtAddress);
			base.Controls.Add(this.label2);
			base.Controls.Add(this.txtName);
			base.Controls.Add(this.label1);
			this.Cursor = Cursors.Hand;
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			base.KeyPreview = true;
			this.MaximumSize = new Size(582, 285);
			this.MinimumSize = new Size(582, 285);
			base.Name = "frmAddSideEffects";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = ".: Tác dụng phụ của thuốc";
			base.Load += new EventHandler(this.frmAddSideEffects_Load);
			base.KeyDown += new KeyEventHandler(this.frmAddSideEffects_KeyDown);
			base.ResumeLayout(false);
			base.PerformLayout();
		}
		public frmAddSideEffects()
		{
			Program.strConnectionString = this.objFunc.strConnectionString;
			this.InitializeComponent();
		}
		private void btnSave_Click(object sender, EventArgs e)
		{
			try
			{
				SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
				sqlConnection.Open();
				SqlCommand sqlCommand = new SqlCommand("ActionOnTabSideEffects", sqlConnection);
				sqlCommand.CommandType = CommandType.StoredProcedure;
				sqlCommand.Parameters.Add("ID", SqlDbType.Int);
				sqlCommand.Parameters.Add("Name", SqlDbType.NVarChar, 250);
				sqlCommand.Parameters.Add("Address", SqlDbType.NVarChar, 500);
				sqlCommand.Parameters.Add("Diagnosis", SqlDbType.NVarChar, 500);
				sqlCommand.Parameters.Add("DrugsUsed", SqlDbType.NVarChar, 500);
				sqlCommand.Parameters.Add("DateStart", SqlDbType.DateTime);
				sqlCommand.Parameters.Add("Description", SqlDbType.NVarChar, 500);
				sqlCommand.Parameters.Add("Measures", SqlDbType.NVarChar, 500);
				sqlCommand.Parameters.Add("Conclution", SqlDbType.NVarChar, 500);
				sqlCommand.Parameters["ID"].Value = int.Parse(this.ID);
				sqlCommand.Parameters["Name"].Value = this.txtName.Text;
				sqlCommand.Parameters["Address"].Value = this.txtAddress.Text;
				sqlCommand.Parameters["Diagnosis"].Value = this.txtDiagnosis.Text;
				sqlCommand.Parameters["DrugsUsed"].Value = this.txtDrugsUsed.Text;
				sqlCommand.Parameters["DateStart"].Value = this.dtpDateStart.Value;
				sqlCommand.Parameters["Description"].Value = this.txtDescription.Text;
				sqlCommand.Parameters["Measures"].Value = this.txtMeasures.Text;
				sqlCommand.Parameters["Conclution"].Value = this.txtConclution.Text;
				sqlCommand.ExecuteNonQuery();
				sqlConnection.Close();
				sqlConnection.Dispose();
				MessageBox.Show("Thông tin đã được lưu vào cở sở dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
			}
			catch
			{
			}
		}
		private void frmAddSideEffects_Load(object sender, EventArgs e)
		{
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			sqlConnection.Open();
			SqlCommand sqlCommand = sqlConnection.CreateCommand();
			sqlCommand.CommandText = "SELECT * FROM [TabSideEffects] WHERE [ID] = " + this.ID;
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			while (sqlDataReader.Read())
			{
				this.txtName.Text = sqlDataReader["Name"].ToString();
				this.txtAddress.Text = sqlDataReader["Address"].ToString();
				this.txtDiagnosis.Text = sqlDataReader["Diagnosis"].ToString();
				this.txtDrugsUsed.Text = sqlDataReader["DrugsUsed"].ToString();
				this.dtpDateStart.Value = DateTime.Parse(sqlDataReader["DateStart"].ToString());
				this.txtDescription.Text = sqlDataReader["Description"].ToString();
				this.txtMeasures.Text = sqlDataReader["Measures"].ToString();
				this.txtConclution.Text = sqlDataReader["Conclution"].ToString();
			}
			sqlDataReader.Close();
			sqlConnection.Close();
			sqlConnection.Dispose();
		}
		private void btnClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void frmAddSideEffects_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
			else
			{
				if (e.KeyCode == Keys.F6)
				{
					this.btnSave.PerformClick();
				}
			}
		}
	}
}
